﻿using System.Reflection;
using NHibernate.Linq.Functions;

namespace NHDay_Linq.ProviderExtensions
{
	public class EqualsRuntimeHqlGenerator : IRuntimeMethodHqlGenerator
	{
		private readonly IHqlGeneratorForMethod _equalsGenerator = new EqualsObjectGenerator();

		#region IRuntimeMethodHqlGenerator Members

		public bool SupportsMethod(MethodInfo method)
		{
			// the check about the name is to make things a little be fasters
			return method != null && method.Name == "Equals";
		}

		public IHqlGeneratorForMethod GetMethodGenerator(MethodInfo method)
		{
			return _equalsGenerator;
		}

		#endregion
	}
}
